-
Notifications
You must be signed in to change notification settings - Fork 82
Replace NAMEKEY strings with defines #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change is wip but I can already add some notes :)
Perhaps the next step (in a follow up change) would be to change name key string to name key hash and have these hashes of names generated at compile time. The original string could perhaps be preserver for debug in a NameKey struct, that contains both hash and string.
@@ -1409,7 +1409,7 @@ void ControlBar::update( void ) | |||
Int count; | |||
const ThingTemplate *thing = TheThingFactory->findTemplate( ThePlayerList->getLocalPlayer()->getPlayerTemplate()->getBeaconTemplate() ); | |||
ThePlayerList->getLocalPlayer()->countObjectsByThingTemplate( 1, &thing, false, &count ); | |||
static NameKeyType beaconPlacementButtonID = NAMEKEY("ControlBar.wnd:ButtonPlaceBeacon"); | |||
static NameKeyType beaconPlacementButtonID = NAMEKEY(NAMEKEY_ControlBar.wnd:ButtonPlaceBeacon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these related for sure?
@@ -1409,7 +1409,7 @@ void ControlBar::update( void ) | |||
Int count; | |||
const ThingTemplate *thing = TheThingFactory->findTemplate( ThePlayerList->getLocalPlayer()->getPlayerTemplate()->getBeaconTemplate() ); | |||
ThePlayerList->getLocalPlayer()->countObjectsByThingTemplate( 1, &thing, false, &count ); | |||
static NameKeyType beaconPlacementButtonID = NAMEKEY("ControlBar.wnd:ButtonPlaceBeacon"); | |||
static NameKeyType beaconPlacementButtonID = NAMEKEY(NAMEKEY_ControlBar.wnd:ButtonPlaceBeacon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string concat is expected to be NAMEKEY_ControlBar ".wnd:ButtonPlaceBeacon"
(I am not sure what NAMEKEY does) or make them explicit ones like you have for some others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namekey is essentially a hashing function for the characters passed into it.
This is also what gets used with the player name and in a few other placers.
Was there any other work to be done with this? it does need a rebase with recent main and is still set to draft. |
will close for now, i'm busying with a ton of other projects atm. |
WIP.
Replaces a lot of strings with defines. No behavior change, this simply hardens against typos causing silent bugs in the future.